// pages/save/save.js
Page({

	/**
	 * 页面的初始数据
	 */
	data: {
		num:1,
		data:[],
		pd:0,
		sta:'all',
		list:[]
	},

	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad: function(options) {
		wx.getStorage({
			key:'uid',
			success:(e)=>{
				this.setData({
					uid:e.data.uid
				})
				this.res()
			}
		})
	},
	res(){
		wx.request({
			url: getApp().globalData.xc,
			method: "POST",
			header: {
				"Content-Type": "application/x-www-form-urlencoded"
			},
			data: {
				HTTP_API: 'vv/order/api/index/getOrderList',
				status:this.data.sta,
				page:this.data.num,
				token:this.data.uid,
				pagesize:20
			},
			success:(e)=>{
				console.log(e)
				if(e.data.data.list.length<20){
					this.setData({
						pd:1
					})
				}
				let a=this.data.list
				e.data.data.list.forEach(function(item,index){
					item.little_time=new Date(parseInt(item.little_time) * 1000).toLocaleString().replace(/:\d{1,2}$/,' ');
					item.finishtime=new Date(parseInt(item.finishtime) * 1000).toLocaleString().replace(/:\d{1,2}$/,' ');
					a.push(item)
				})
				console.log(e)
				this.setData({
					data:e.data.data,
					list:a
				})
			}
		})
	},
	ovo() {
		if (this.data.pd == 0) {
			console.log(1)
			let a = this.data.num + 1
			this.setData({
				num: a
			})
			this.res()
		}
	},
	index(e){
		this.setData({
			list:[],
			sta:e.currentTarget.dataset.id,
		})
		this.res()
	},
})
